var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, n) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var n in t)
              Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
          })(t, n);
      };
      return function (t, n) {
        function i() {
          this.constructor = t;
        }
        if ("function" != typeof n && null !== n)
          throw new TypeError(
            "Class extends value " + String(n) + " is not a constructor or null"
          );
        e(t, n),
          (t.prototype =
            null === n
              ? Object.create(n)
              : ((i.prototype = n.prototype), new i()));
      };
    })(),
  HunDanWearDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        WebSocketService.addListener({
          caller: t,
          code: 6184,
          method: t.onLoadHunDanDetailsData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6188,
          method: t.onLoadHunDanBeiBaoData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6186,
          method: t.onLoadHunDanActionData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6187,
          method: t.onLoadFuJiangHunDanActionData,
        }),
        t.btn_hundan_xishou.on(Laya.Event.CLICK, t, t.onDidClickHunDanAction),
        t.btn_hundan_shengji.on(Laya.Event.CLICK, t, t.onDidClickHunDanAction),
        t.btn_hundan_xiexia.on(Laya.Event.CLICK, t, t.onDidClickHunDanAction),
        (t.list_hundan_beibao.vScrollBarSkin = ""),
        (t.list_hundan_beibao.selectEnable = !0),
        t.list_hundan_beibao.on(Laya.Event.CLICK, t, t.onDidClickHunDanAction),
        (t.list_hundan_beibao.renderHandler = new Laya.Handler(
          t,
          t.updateHunDanItemRender
        )),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showHunDanDialog = function (e) {
        return (
          null == this.hundanV &&
            ((this.hundanV = new t()), (this.hundanV.zOrder = 1e3)),
          this.hundanV.popup(),
          (this.hundanV.objJson = {}),
          (this.hundanV.objJson = e),
          (this.hundanV.controller = ""),
          (this.hundanV.objId = ""),
          e.controller && (this.hundanV.controller = e.controller),
          e.id
            ? (e.cid
                ? WebSocketService.send({
                    c: 6184,
                    d: { id: e.id, cid: e.cid },
                  })
                : WebSocketService.send({ c: 6184, d: { id: e.id, cid: 0 } }),
              this.hundanV.dealAllowButton(!0))
            : (this.hundanV.dealAllowButton(!1),
              (this.hundanV.label_hundan_descr.text = ""),
              (this.hundanV.label_hundan_mainTitle.text = "")),
          "AXSuboardinateDetailView" == e.controller
            ? WebSocketService.send({ c: 6188, d: { cid: e.cid, pageNum: 0 } })
            : "UserInfoView" == e.controller &&
              WebSocketService.send({ c: 6188, d: { cid: 0, pageNum: 0 } }),
          this.hundanV
        );
      }),
      (t.prototype.dealAllowButton = function (e) {
        (this.btn_hundan_xishou.visible = e),
          (this.btn_hundan_shengji.visible = e),
          (this.btn_hundan_xiexia.disabled = !e);
      }),
      (t.prototype.onLoadHunDanDetailsData = function (e) {
        if (0 == e.code) {
          var t = e.data;
          this.label_hundan_mainTitle.text = t.lvl + "级 " + t.name;
          var n = "职业：" + this.dealZhiYeString(t.t),
            i = "状态：" + (1 == t.ss ? "已激活" : "归元"),
            a = "效果：" + t.descr,
            o = "魂值：" + t.e + "/" + t.eUp,
            d = "升级耗银：" + t.silver;
          (this.label_hundan_descr.text =
            n + "\n" + i + "\n" + a + "\n" + o + "\n" + d),
            (this.objId = e.data.id),
            (this.sLvl = e.data.lvl),
            (this.sName = e.data.name),
            this.objJson.cid
              ? WebSocketService.send({
                  c: 6188,
                  d: { cid: this.objJson.cid, pageNum: 0 },
                })
              : WebSocketService.send({ c: 6188, d: { cid: 0, pageNum: 0 } }),
            this.dealAllowButton(!0);
        } else
          ToastView.toastView(e.msg),
            this.dealAllowButton(!1),
            (this.label_hundan_descr.text = ""),
            (this.label_hundan_mainTitle.text = "");
      }),
      (t.prototype.onLoadHunDanBeiBaoData = function (e) {
        if (0 == e.code) {
          this.beiBaoArr = [];
          for (var t = void 0, n = 0; n < e.list.length; n++) {
            var i = e.list[n];
            (t = {
              hundanName: { text: i.lvl + "级 " + i.name + " " + i.desc },
              id: i.id,
              type: i.type,
            }),
              this.beiBaoArr.push(t);
          }
          this.list_hundan_beibao.dataSource = this.beiBaoArr;
        }
      }),
      (t.prototype.onDidClickHunDanAction = function (e) {
        if ("" != e.target.name) {
          var t = "",
            n = "";
          if ("hundanButton" == e.target.name) {
            var i = this.list_hundan_beibao.selectedItem;
            (t = i.id), (n = "2"), (this.objId = i.id);
          } else {
            if ("hundanxishou" == e.target.name) {
              var a = {
                id: this.objId,
                cid: this.objJson.cid,
                lvl: this.sLvl,
                name: this.sName,
              };
              return void AXHunDanDetailsDialog.showHunDanDialog(
                a,
                "HunDanWearDialog"
              );
            }
            "hundanshengji" == e.target.name
              ? ((t = this.objId), (n = "5"))
              : "hundanxiexia" == e.target.name &&
                ((t = this.objId), (n = "1"));
          }
          if ("AXSuboardinateDetailView" == this.controller) {
            -1 == (o = e.target.name).indexOf("item") &&
              ("1" == n
                ? WebSocketService.send({
                    c: 6187,
                    d: { cid: this.objJson.cid, sid: t, act: n },
                  })
                : "2" == n
                ? WebSocketService.send({
                    c: 6187,
                    d: { cid: this.objJson.cid, sid: t, act: n },
                  })
                : WebSocketService.send({ c: 6186, d: { id: t, act: n } }));
          } else {
            var o = e.target.name;
            -1 == o.indexOf("item") &&
              WebSocketService.send({ c: 6186, d: { id: t, act: n } });
          }
        }
      }),
      (t.prototype.onLoadHunDanActionData = function (e) {
        6186 == e.act_id
          ? (0 == e.code &&
              (1 == e.data
                ? ((this.label_hundan_mainTitle.text = "无魂蛋详情"),
                  (this.label_hundan_descr.text = "暂无装备魂蛋"),
                  (this.objId = ""),
                  this.objJson.cid
                    ? WebSocketService.send({
                        c: 6188,
                        d: { cid: this.objJson.cid, pageNum: 0 },
                      })
                    : WebSocketService.send({
                        c: 6188,
                        d: { cid: 0, pageNum: 0 },
                      }),
                  this.dealAllowButton(!1))
                : 2 == e.data
                ? ((this.label_hundan_descr.text = ""),
                  (this.label_hundan_mainTitle.text = ""),
                  WebSocketService.send({
                    c: 6184,
                    d: { id: this.objId, cid: 0 },
                  }),
                  this.dealAllowButton(!0))
                : 3 == e.data
                ? ((this.label_hundan_descr.text = ""),
                  (this.label_hundan_mainTitle.text = ""),
                  WebSocketService.send({
                    c: 6184,
                    d: { id: this.objId, cid: 0 },
                  }),
                  this.dealAllowButton(!0))
                : 5 == e.data &&
                  (this.objJson.cid
                    ? WebSocketService.send({
                        c: 6184,
                        d: { id: this.objId, cid: this.objJson.cid },
                      })
                    : WebSocketService.send({
                        c: 6184,
                        d: { id: this.objId, cid: 0 },
                      }),
                  ToastView.toastView(e.msg)),
              this.list_hundan_beibao.refresh(),
              this.objJson.cid
                ? WebSocketService.send({
                    c: 1009,
                    d: { id: this.objJson.cid },
                  })
                : WebSocketService.send({ c: 1e3, d: null })),
            ToastView.toastView(e.msg))
          : this.list_hundan_beibao.refresh();
      }),
      (t.prototype.updateHunDanItemRender = function (e, t) {
        var n = e.getChildByName("hundanButton");
        (n.visible = !0), this.objId && (n.visible = !1);
      }),
      (t.prototype.onLoadFuJiangHunDanActionData = function (e) {
        0 == e.code
          ? (1 == e.data
              ? ((this.label_hundan_mainTitle.text = "无魂蛋详情"),
                (this.label_hundan_descr.text = "暂无装备魂蛋"),
                (this.objId = ""),
                this.objJson.cid
                  ? WebSocketService.send({
                      c: 6188,
                      d: { cid: this.objJson.cid, pageNum: 0 },
                    })
                  : WebSocketService.send({
                      c: 6188,
                      d: { cid: 0, pageNum: 0 },
                    }),
                this.dealAllowButton(!1))
              : 2 == e.data
              ? ((this.label_hundan_descr.text = ""),
                (this.label_hundan_mainTitle.text = ""),
                WebSocketService.send({
                  c: 6184,
                  d: { id: this.objId, cid: this.objJson.cid },
                }),
                this.dealAllowButton(!0))
              : e.data,
            this.list_hundan_beibao.refresh(),
            "AXSuboardinateDetailView" == this.controller
              ? WebSocketService.send({ c: 1009, d: { id: this.objJson.cid } })
              : WebSocketService.send({ c: 1e3, d: null }),
            ToastView.toastView(e.msg))
          : 8 == e.code &&
            (this.list_hundan_beibao.refresh(), ToastView.toastView(e.msg));
      }),
      (t.prototype.dealZhiYeString = function (e) {
        var t = "";
        return (
          1 == e
            ? (t = "武士")
            : 2 == e
            ? (t = "文人")
            : 3 == e && (t = "异人"),
          t
        );
      }),
      t
    );
  })(ui.UserInfoController.HunDanWearDialogUI);
